<%--
Created by IntelliJ IDEA.
User: hansonghe
Date: 15/10/12
Time: 17:09
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/resource/css/main.css" />
    <style type="text/css">
        td{
            text-align: center;
            border: solid grey 1px;
        }
    </style>
    <script type="text/javascript" src="/resource/script/jquery.js"></script>
    <script type="text/javascript" src="/resource/script/jquery.watermark.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#txtTelNum").watermark({
                watermarkText: "用户的手机号",
                className: "watermark"
            });

            $("#btnSearch").click(function(){
                var tel = $("#txtTelNum").val();
                $.post("/barber/search",
                    {
                        telNum:tel
                    },
                    function(data, status){
                        if(status == "success"){
                            if (data.result){
                                $("#tBarberInfo").show();
                                $("#pTelNum").text(data.telNum);
                                $("#pRealName").text(data.realName);
                                $("#pNickName").text(data.nickName);
                                $("#pShopName").text(data.shopName);

                                $("#btnOp1").hide();
                                $("#btnOp2").hide();
                                if (data.status == 1){
                                    $("#btnOp1").show();
                                }
                                else {
                                    $("#btnOp2").show();
                                }
                            }
                            else {
                                $("#tBarberInfo").hide();
                                alert(data.errorMsg);
                            }
                        }
                        else {
                            alert("网络请求出错，请重新再试！");
                        }

                    }
                );
            });

            $("#btnOp1").click(function(){
                barberOp(true);
            });
            $("#btnOp2").click(function(){
                barberOp(false);
            });
        });

        // true.禁用  false.启用
        function barberOp(opType){
            $.post("/barber/op",
                {
                    action:opType,
                    telNum:$("#pTelNum").text()
                },
                function(data, status){
                    if(status == "success"){
                        if (data.result){
                            if (opType){
                                $("#btnOp1").hide();
                                $("#btnOp2").show();
                                alert("技师" + data.telNum + "已被禁用！");
                            }
                            else {
                                $("#btnOp2").hide();
                                $("#btnOp1").show();
                                alert("技师" + data.telNum + "已被启用！");
                            }
                        }
                        else {
                            alert(data.errorMsg);
                        }
                    }
                    else {
                        alert("网络请求出错，请重新再试！");
                    }
                }
            );
        }
    </script>
</head>
<body>
<input id="txtTelNum" type="text" style="width: 313px; height: 40px; padding-left: 15px; padding-right: 15px; left:50px; top: 50px; border: none; background-image: url('/resource/img/search_input.png')" />
<input id="btnSearch" type="button" style="width: 40px; height: 40px;-moz-background-size:100% 100%; background-size:100% 100%; background-image: url('/resource/img/search.png')" >

<table id="tBarberInfo" style="display: none; border: solid grey 1px;">
    <tr>
        <td>手机号</td>
        <td>真实姓名</td>
        <td>昵称</td>
        <td>所属门店</td>
        <td>操作</td>
    </tr>
    <tr>
        <td width="120px"><p id="pTelNum"></p></td>
        <td width="120px"><p id="pRealName"></p></td>
        <td width="120px"><p id="pNickName"></p></td>
        <td width="400px"><p id="pShopName"></p></td>
        <td width="70px">
            <input id="btnOp1" type="button" value="禁用" />
            <input id="btnOp2" type="button" value="启用" />
        </td>
    </tr>
</table>
</body>
</html>